package com.mz.mattress.client.api.biz;

import com.mz.mattress.api.common.Result;
import com.mz.mattress.client.service.impl.WxPayProcess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/wxPay")
public class WxPayController {

    @Autowired
    private WxPayProcess wxPayProcess;

    @RequestMapping(value = {"/payCallback/{orderId}"})
    public String payCallback(HttpServletRequest request,
                              @PathVariable(value = "orderId", required = false) String orderId) {
        return wxPayProcess.payCallback(request, orderId);
    }

    @RequestMapping(value = {"/refundCallback/{orderId}"})
    public String refundCallback(HttpServletRequest request,
                                 @PathVariable(value = "orderId", required = false) String orderId) {
        return wxPayProcess.refundCallback(request, orderId);
    }

    @GetMapping("/test")
    public Result test() {
        return Result.ok();
    }
}
